package org.geektimes.projects.userweb.controller;

import org.geektimes.projects.userweb.model.User;
import org.geektimes.projects.userweb.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: jipeng
 * @Description:
 * @Date: Created in 2021/5/4 22:57
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/find/{userId}")
    public String findUser(@PathVariable Long userId) {
        User user = userService.getUser(userId);
        return user == null ? "null" : user.toString();
    }



    @GetMapping("/delete/{userId}")
    public String delUser(@PathVariable Long userId) {
        return userService.delUser(userId);
    }


}
